//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_checkmtshothd.sqf"
#include "x_setup.sqf"

private ["_tower","_sel", "_dmg", "_val","_ammo","_selection"];
_tower = _this select 0;
_sel = _this select 1;
_ammo = _this select 4;
_dmg = 0;
// TYRGHEN we override the damage dealt to the tower to not take into account the armor of the tower.
if (_sel == "" && {toUpper(getText(configFile/"CfgAmmo"/(_this select 4)/"simulation")) in GVAR(hd_sim_types)}) then {
	_dmg = 1 / GVAR(MTTowerChargesNeeded);
} else {
	if (GVAR(MTTowerSatchelsOnly) == 1 && {getText(configFile/"CfgAmmo"/(_this select 4)/"CraterEffects") == "BombCrater"}) then {
		_dmg = _this select 2;
	};
};
_val = _tower getVariable QGVAR(damt);
if (!isNil "_val") then {_dmg = _dmg + _val};
_tower setVariable [QGVAR(damt), _dmg];
__TRACE_1("_dmg","_dmg")
_dmg